package com.test.demo;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Vibrator;

import com.example.myprojectoffeixue.R;
import com.macrovideo.objects.ObjectAlarmMessage;
import com.macrovideo.objects.PTZXPoint;
import com.macrovideo.sdk.custom.DeviceInfo;
import com.macrovideo.sdk.custom.RecordFileInfo;
import com.macrovideo.sdk.defines.Defines;
import com.macrovideo.sdk.media.LoginHandle;
import com.macrovideo.sdk.setting.AlarmAndPromptInfo;
import com.macrovideo.sdk.setting.RecordInfo;

public class LocalDefines {
	

	public static int areaID = 0; // add by mai 20151218 ��ŵ�ǰ�����id
	public static LoginHandle Device_LoginHandle = null;  //add by mai 20151215
	
	//�����������ʹ��
	public static boolean B_ALTER_PASSWORD = false;  //add by mai 2015-5-14 �ж��Ƿ����޸���������
	public static boolean B_TESTING_PASSWORD = false; // add by mai 2015-5-14 �ж��Ƿ�����֤�������
	public static boolean B_OFF_PASSWORD = false; // add by mai 2015-5-14 �ж��Ƿ�����Ҫ�ر���������
	public static boolean B_INTENT_ACTIVITY = false; //add by mai 2015-5-15 ��ʦ�Ƿ���ת�����activity
	public static boolean B_DELETE_PASSWORD = false;  // add by mai 2015-6-5 ���Ϊɾ������ 
	public static boolean B_CREATE_PASSWORD = false; //add by mai 2015-6-5 �ж��Ƿ��Ǵ�������
	public static boolean SOFTWARE_PASSWORD_OPEN = false; //add by mai 2015-6-5 �жϵ�ǰ�Ƿ�������
	public static String SOFTWARE_PASSWORD_STATE = "software_password_state"; // add by mai 2015-6-5 
	//========
	
	
	//===������ʾ
	public static int nClientDeviceSettingThreadID=0;
	public static int nClientRegistThreadID=0;
	public static boolean isVibrate=false;
	public static boolean isSound=false;
	public static String strSysLan = null;  //add by mai 2015-5-27 ��ȡ�ֻ���ǰ������
	public static String SOUND_SHAKE_STORE_NAME = "ShoundShake";  // add by mai 2015-4-3 SharedPreferences �洢����
	public static String DEVICE_MESSAGE_RECEIVE = "alarmMessageReceive"; // add by mai 2015-6-8 �洢�Ƿ���������Ϣ
	public static String ALARM_SOUND = "alarm_sound";  // add by mai 2015-4-3 ��ȡ��������������
	public static String ALARM_SHAKE = "alarm_shake";  //add by mai 2015-4-3 ��ȡ�𶯵���������
	public static String RECV_ALARM_MSG = "recv_msg"; // add by mai 2015-5-27 ��ȡ�Ƿ���ձ�����Ϣ��������
	public static String ALARM_DEVICE_LOGIN = "alarmDeviceLogin"; // add by mai 2015-5-27 ��ȡ��һ��ע���Ƿ�ɹ�
	
	public static String ALARM_SETTINGS = "alarm_settings_sharedpreference"; // add by mai 2015-5-27 ��ȡ��һ��ע���Ƿ�ɹ�
	public static boolean isRecvMsg = true;  // add by mai 2015-5-26 ����ȫ�ֿ��������ֻ��Ƿ���ձ�����Ϣ
	public static void loadAlarmSettings(Activity context){
		if(context==null)return;
		SharedPreferences alarmSettingSharedPreferences=context.getSharedPreferences(ALARM_SETTINGS, Activity.MODE_APPEND);;
		if(alarmSettingSharedPreferences!=null){
			isRecvMsg = alarmSettingSharedPreferences.getBoolean(RECV_ALARM_MSG, true);
			isVibrate=alarmSettingSharedPreferences.getBoolean(ALARM_SHAKE, false);
			isSound=alarmSettingSharedPreferences.getBoolean(ALARM_SOUND, true);
		}
		
		strSysLan = context.getString(R.string.country_code);
	}
	
	public static void saveAlarmSettings(Activity context){
		if(context==null)return;
		SharedPreferences alarmSettingSharedPreferences=context.getSharedPreferences(ALARM_SETTINGS, Activity.MODE_APPEND);;
		if(alarmSettingSharedPreferences!=null){
			Editor editor = alarmSettingSharedPreferences.edit();
			if(editor!=null){
				editor.putBoolean(RECV_ALARM_MSG, isRecvMsg);
				editor.putBoolean(ALARM_SHAKE, isVibrate);
				editor.putBoolean(ALARM_SOUND, isSound);
				editor.commit();
			}
			 
		}
	}
	
	//********
	
	
	//add by luo 20150805
	public static boolean _isQRResultOK=false;
	public static int _nQRResultDevice=0;
	//end add by luo 20150805
	
	public static DeviceInfo DEVICE_MSG = null;  //�����豸���ô�ŵ�ǰ�Ѿ�����˵��豸��Ϣ add by mai 2015-4-8
	public static ArrayList<DeviceInfo> _severInfoListData=new ArrayList<DeviceInfo>();
//不见了

    public static int _PlatbackListviewSelectedPosition=0;//add by luo 20141010 �б������λ��
    public static int _PlatbackRecListviewFisrtPosition=0;//add by luo 20141010 �б������λ��
    public static DeviceInfo configDeviceInfo = null; // add by mai 2015-6-15  ��ŵ�ǰ���������
    public static boolean bIsConfig = false; // add by mai 2015-6-15 ��ʶ��ǰ������豸���õ�ĳ���� ���ڿ���back��
	public static boolean bIsBackPlay = false; // add by mai 2015-10-16 ��ʶ��ǰ���¼��ط��б�
	
	
	//����Ǹ�����
	static final int PAGE_INDEX_SERVERLIST=10;
	static final int PAGE_INDEX_ADDDEVICE=11;
	static final int PAGE_INDEX_MODIFYDEVICE=12;
	static final int PAGE_INDEX_CONFIG=13;
	static final int PAGE_INDEX_CONFIG_NETWORK=14;
	static final int PAGE_INDEX_CONFIG_RECORD=15;
	static final int PAGE_INDEX_CONFIG_DATETIME=16;
	static final int PAGE_INDEX_CONFIG_ACOUNT=17;
	static final int PAGE_INDEX_CONFIG_VERSION=18;
	static final int PAGE_INDEX_CONFIG_ALARMANDPROMPT=19;//add by luo 20141011
	//=====
	
	//�豸����ӷ�ʽ
	public static int SERVER_SAVE_TYPE_ADD = 1011;//
	public static int SERVER_SAVE_TYPE_SEARCH=1012;//
	public static int SERVER_SAVE_TYPE_DEMO=1013;//
	//=======
	
	
	//�豸����״̬
	public static final int ON_LINE_STAT_UNKNOW = -1;//���ڼ��
	public static final int ON_LINE_STAT_READY = 0;//��������
	public static final int ON_LINE_STAT_OFF = 100;//����
	public static final int ON_LINE_STAT_LAN = 101;//����������
	public static final int ON_LINE_STAT_WAN = 102;//����������
	//======
	
	//��������ʽ
    static final int SERVER_TYPE_DOMAIN = 100;//����
    static final int SERVER_TYPE_IP = 101;//ip��ַ
    
    //��������
    public static final int NV_LANGUAGE_CN=1000; //����
    public static final int NV_LANGUAGE_EN=1100;//Ӣ��
    
    public static final int EXALARMMODE_EXTERNAL=10;	//�ⲿ����ϵͳ(expand detector)
    public static final int EXALARMMODE_INTERNAL=11;	//�ڲ�����ϵͳ(current detector)
    public static final int EXALARMMODE_MANUALOFF=12;	//�ֶ����ƹر����(manually control)
    public static final int EXALARMMODE_MANUALON=13;	//�ֶ����ƿ������(manually control)
    public static AlarmAndPromptInfo _AlarmAndPromptConfig= new AlarmAndPromptInfo();
	public static final int ALARM_MODEL_315 = 315; //�����豸��315
	public static final int ALARM_MODEL_433 = 433; //�����豸��433
	public static final int NV_IPC_REMOTE_GET_REQUEST = 880;  //Զ�̻�ȡ
	public static final int NV_IPC_REMOTE_SET_REQUEST = 881;  //Զ������
	public static DeviceInfo alarmRelecanceDeviceInfo = null;
	
	
	public static final int notificationAlarmID = 0x000102;
	public static final int notificationID = 0x000101;
	
	
	//�����豸����
	public static final int DEVICE_OTHER = 0; //����
	public static final int DEVICE_ACCESS_CTRL = 1; //�Ž�
	public static final int DEVICE_SMOKE_FEELING = 2; //�̸�
	public static final int DEVICE_GAS = 3; //ú��
	public static final int DEVICE_WARM_FEELING = 4; //�¶�
		
	//��������
	public static final int ALARM_LEVEL_L = 1; // ��
	public static final int ALARM_LEVEL_M = 2; //��
	public static final int ALARM_LEVEL_H = 3; //��
	
	
	//add by mai 2015-8-14
	public static final int NV_IP_ALARM_DEVICE_LIST_REQUEST = 130;  //��ȡ����ӵı����豸ָ����
	public static final int NV_IP_ALARM_DEVICE_LIST_RESPONSE = 230; // ��ȡ����ӵı����豸����ָ����
	public static final int NV_IP_ALARM_DEVICE_SEARCH_REQUEST = 131; // ���ֱ����豸(�豸����)ָ����
	public static final int NV_IP_ALARM_DEVICE_SEARCH_RESPONSE  = 231; // ���ֱ����豸(�豸����)����ָ����
	public static final int NV_IP_ALARM_DEVICE_ADD_REQUEST = 132; //��ӱ����豸ָ����
	public static final int NV_IP_ALARM_DEVICE_ADD_RESPONSE  = 232; // ��ӱ����豸����ָ����
	public static final int NV_IP_ALARM_DEVICE_MODIFY_REQUEST = 133; //�޸ı����豸ָ����
	public static final int NV_IP_ALARM_DEVICE_MODIFY_RESPONSE = 233; //�޸ı����豸����ָ����
	public static final int NV_IP_ALARM_DEVICE_DELETE_REQUEST = 134; //ɾ�������豸ָ����
	public static final int NV_IP_ALARM_DEVICE_DELETE_RESPONSE = 234; // ɾ�������豸����ָ����
	public static final int ALARM_DEVICE_SEARCH_ON  = 100; // ��ʼ����
	public static final int ALARM_DEVICE_SEARCH_OFF = 101; //�رռ���
	
	public static final int NV_RESULT_SUCCEED = 1001; //�������Ϊ�ɹ�
	public static final int NV_RESULT_FAILED = 2001; //�������Ϊʧ��
	
	

	public static ArrayList<DeviceInfo> _severInfoWithoutImageListData=new ArrayList<DeviceInfo>();
	public static boolean isClientRegisted=false;
	public static boolean isDeviceListSet=false;
	public static boolean isDeviceBinded=false;
	public static int reloadDeviceInfoList(){
		
		_severInfoListData.clear();
		_severInfoWithoutImageListData.clear();

		DeviceInfo[] array = DatabaseManager.GetAllServerInfo();
		    
		if (array != null) {
			for (int i = 0; i < array.length; i++) {
				if(array[i]!=null){
					_severInfoListData.add(array[i]);  
					
					_severInfoWithoutImageListData.add(array[i].copyDeviceInfoWithoutImage());
				}
				
			}

		}
		return _severInfoListData.size();
	}
	
	public static final int DOWNREQUEST=100;
    static final int STOPDOWN=101;
    static final int UPLOADQUEST=102;
    static final int STOPUPLOAD=103;
	public static final int FILESTART=110;
	public static final int FILEDATAEND=111;
	public static final int FILEDATA=112;
	public static final int FILEERROR=113;
	public static final int USERVERIFY=167;
	public static final int USERVERIFYRESULT=168;
	public static final int USERVERIFYRESULTMR=169;//ͨ��ת�����������û���¼У��
	public static final int TESTCONNECTION=222;
	public static final int DISCONNECT=253;
	public static final int CUSTOMBUF=254;
	
	static String _DemoMRServer="rs31.nvdvr.cn";
	public static int _DemoMRPort=8800;
	static final String MV_DOMAIN_SUFFIX=".nvdvr.net";
			//add by luo 2013-02-18
	static String _MRServer="127.0.0.1";
	public static int _MRPort=8800;
	public static int _OnLinePort=8900; //add by mai 2015-6-19
	static boolean _bUseMRServer=true;
	public static int _MRServerIndex=0;
	
	public static final int CMD_MR_LOGIN=1001;//׼��ͨѶָ��
	public static final int CMD_MR_PLAY=1002;//��ȡһ֡ͼ��ָ��
	public static final int CMD_MR_GET_IMAGE=1003;//��ȡһ֡ͼ��ָ��
	public static final int CMD_MR_LOGIN_RESPONSE=2001;//��¼ȷ��ָ��
	public static final int CMD_MR_PLAY_RESPONSE=2002;//����ͼ��ȷ��ָ��
	public static final int OS_PHONE_TYPE = Defines.PHONE_TYPE_ANDROID;// �ֻ�����
	
	
	
	
	//ģʽ���壺
	public static final int NV_WIFI_MODE_UNKNOW = 0000; //APģʽ
	public static final int NV_WIFI_MODE_AP = 1001; //APģʽ
	public static final int NV_WIFI_MODE_STATION = 1002; // STATION ģʽ
	public static final int NV_WIFI_MODE_ALL = 1003; // ��Ӧ�ɰ汾��ϵͳ
	
	
	public static boolean B_UPDATE_LISTVIEW = true; // add by mai 2015-3-27 �б��Ƿ���Ҫ����ˢ��
	public static final int LIST_MODE_NORMAL = 200;//����
	public static final int LIST_MODE_EDIT = 201;//ɾ����¼
	public static final int LIST_MODE_SEARCHING = 202;//�����豸
	public static final int LIST_MODE_CONFIG = 203;//�����豸
	public static final int LIST_MODE_DEMONSTRATE = 204;//��ʾ
	
	public static int _nListMode=LIST_MODE_NORMAL;
	
	
	
	 //��������
    public static final int ALARM_MSG_TYPE_UNDIFINED	=111;	// ����
    public static final int ALARM_MSG_TYPE_SMOG			=100;	//������
    public static final int ALARM_MSG_TYPE_MOTION		=200;	//�ƶ�����
    public static final int ALARM_MSG_TYPE_PIR			=300;	//PIR �����Ӧ����
    public static final int ALARM_MSG_TYPE_ACCESS_CTRL	=400;	//�Ž�����
    public static final int ALARM_MSG_TYPE_GAS			=500;	//ú������
    public static final int ALARM_MSG_TYPE_WARM			=600;	//�¶ȱ���

    public static final int CRITICAL =300;		//���ظ澯
    public static final int MAJOR =400;		//�ش�澯
    public static final int MINOR =500;		//��Ҫ�澯
    public static final int NOTICE =600;		//��ʾ��Ϣ
	
	 //��������
	private static  SoundPool soudPool=null;
	private static int sourceid_alarm_notice=0;
	private static int sourceid_alarm_warm=0;
	private static long lPlayTime = 0;
	private static Vibrator vibrator=null;  //add by mai 2015-4-3 ����ϵͳ��
	@SuppressWarnings("deprecation")
	public static synchronized void initNoticeSound(Context context){
		if(soudPool==null){
			
			soudPool = new SoundPool(1, AudioManager.STREAM_SYSTEM, 5); 
		}
	
		sourceid_alarm_notice = soudPool.load(context, R.raw.alarm_notice, 0); 
		sourceid_alarm_warm = soudPool.load(context, R.raw.alarm_warm, 0);

			if(vibrator==null){
				vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);  // ������
			}
			
	}
	public static synchronized void playNoticeSound(int nAlarmType){

		 if(System.currentTimeMillis() - lPlayTime<=1000) return;
		 
		if(isSound && soudPool!=null){
			
			if(nAlarmType==ALARM_MSG_TYPE_SMOG || 
		    		nAlarmType==ALARM_MSG_TYPE_PIR || 
		    		nAlarmType==ALARM_MSG_TYPE_ACCESS_CTRL ||
		    		nAlarmType==ALARM_MSG_TYPE_GAS ||
		    		nAlarmType==ALARM_MSG_TYPE_WARM){
				soudPool.play(sourceid_alarm_warm, 1, 1, 0, 0, 1);
		    }else{
		    	soudPool.play(sourceid_alarm_notice, 1, 1, 0, 0, 1);
		    }
			
			lPlayTime = System.currentTimeMillis();
		}
		
		if(isVibrate && vibrator!=null)
		{  
//			long [] pattern = {500,1000,500,1000};   // ֹͣ ���� ֹͣ ����   
	        vibrator.vibrate(pattern,-1);           //�ظ�һ�������patternֻ�ظ�һ�����Ϊ-1
	       // vibrator.cancel();
		}
		
	}
	
	static final long [] pattern = {500,1000,500,1000};   // ֹͣ ���� ֹͣ ����
	public static final int HANDLE_SHOW_WINDOW_ADD=0x111;//��Ϣ�����ʾ�𣺻�ȡ�������ý��
	public static boolean _isNeedGetPreviewDeviceList=true;
	public static ArrayList<DeviceInfo> _demoSeverInfoListData=new ArrayList<DeviceInfo>();
	//不见了

    public static String PUSH_RECEIVER = "com.macrovideo.update.push"; //add by mai 2015-6-4 �㲥��ʶ
    public static String PUSH_TITLE = "pushTitle"; // add by mai 2015-6-4 ������Ϣ״̬��ʾ��ͷ
    public static String PUSH_TYPE = "pushType"; // add by mai 2015-6-4 �������͹�������Ϣ������
    public static String PUSH_MSG = "pushMsg"; //add by mai 2015-6-4 �������͹�����Ϣ������
    public static String PUSH_TIME = "pushTime"; //add by mai 2015-6-4 �������͹�������Ϣ��ʱ��
    public static String PUSH_ID = "pushId"; //add by mai 2015-6-4 �������͹�������Ϣ��id
    public static int _listviewFisrtPosition=0;//add by luo 20141010 �б������λ��
    public static ArrayList<ServerInfoForAlarm> _severInfoListDataForAlarm=new ArrayList<ServerInfoForAlarm>();
    
    
    public static int loadDeviceList(boolean isCheck){
		int nCount =0;
		if(isCheck){
			if(_severInfoListData.size()>0){
				return _severInfoListData.size();
			}
		}
		
		
		// add by luo 20141030
		if (_severInfoListData.size() > 0) {
			for (int i = _severInfoListData.size() - 1; i >= 0; i--) {
				DeviceInfo info = _severInfoListData.get(i);
				if (info != null) {
					info.releaseImage();
				}
			}

			System.gc();// add by luo 20141223
		}
		// end add by luo 20141030

		reloadDeviceInfoList();
		
		return nCount;
	}
    
    
    
  //�豸�������ֵ
  public static final int DEVICE_SEARCH_RESULT=1001;//add by luo 2013-04-15 �豸�������
  public static final int DEVICE_SEARCH_RESULT_OK=101;//add by luo 2013-04-15 �豸�������
  public static final int DEVICE_SEARCH_RESULT_FAIL=102;//add by luo 2013-04-15 �豸�������
  	
  public static final int DEVICE_IP_UPDATE=1002;//add by luo 2013-04-15 �豸�������
  		
  public static final int DEVICE_SOUND_WAVE_END=1003;//add by luo 20150407�豸�������
  public static final int NV_DEVICE_NET_STATE_ONLINE = 1200; // add by mai 2015-6-19 �豸����Զ��ˢ�³ɹ�
  
  
  
  public static int _nAlarmPort =8888;  //�����������˿ں�
  public static String _strAlarmServer = "alarm1.nvdvr.cn";  //��������������
  
  public static String _strDeviceDemoServer = "preview.nvdvr.cn";  //��ʾ�����������
  public static final int ALARM_SUCCESS = 0; //��ȡ������Ϣ�ɹ�
  public static final int ALARM_FALLURE = 1; //��ȡ������Ϣʧ��
  public static final String JSP_SERVER_CONNECT_MSG = "/GetAlarmMsg/AlarmSelectServletMsg?param=";  //��ȡ������������
  public static final String JSP_SERVER_CONNECT_PICTURE = "/GetAlarmMsg/AlarmSelectServletPicture?param=";  //��ȡ������ϸ��Ϣ����
  public static final String JSP_SERVER_CONNECT_PICTURE_CONDITION = "/GetAlarmMsg/AlarmSelectServletPictureCondition?param=";  //��ȡ������ϸ��Ϣ����
  public static final String JSP_SERVER_CONNECT_PICTURE_LARGE = "/GetAlarmMsg/AlarmSelectServletPictureByID?param=";  //��ȡ������ϸ��Ϣ����
  public static final String JSP_SERVER_CONNECT_PICTUER_PREVIEW ="/GetAlarmMsg/PreviewSelectServletDeviceInfo?param="; //��ʾ��
  public static final String JSP_SERVER_CONNECT_PICTUER_PREVIEW_DEFAULT ="/GetPreviewServer/PreviewSelectServletDeviceInfo?param="; //��ʾ��
  
  
  public static final int NV_IPC_ONLINE_CHECK_REQUEST = 172; //add by mai 2015-6-18 ���߼������ָ��
  public static final int NV_IPC_ONLINE_CHECK_RESPONSE = 272; // add by mai 2015-6-18 ���߼�ⷵ��ָ��
  public static final int NV_IPC_ONLINE_CHECK_ONLINE = 1; // add by mai 2015-6-18 ��ʾ�豸����
  public static final int NV_IPC_ONLINE_CHECK_OFFLINE = 0; // add by mai 2015-6-18 ��ʶ�豸������
  public static final int NV_IPC_ONLINE_CHECK_UNKNOWN = 10; // add by mai 2015-6-18 ��ʶ�豸������
  
  public static final int HANDLE_MSG_CODE_WIFI_SEARCH_RESULT=0x20;//��Ϣ�����ʾ�𣺵�¼���
  public static final int WIFI_SEARCH_RESULT_CODE_SUCCESS=0x0011;//WIFI�����ɹ�
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_NET_DOWN=0x1011;//WIFI����ʧ��-���粻ͨ
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_NET_POOL=0x1012;//WIFI�����ɹ�-�������ӳ�ʱ
	
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_SERVER_OFFLINE=0x1013;//WIFI����ʧ��-������������
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_VERIFY_FAILED=0x1014;//WIFI����ʧ��-��֤����
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_USER_NOEXIST=0x1015;//WIFI����ʧ��-�û���������
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_PWD_ERROR=0x1016;//WIFI����ʧ��-�������
  public static final int WIFI_SEARCH_RESULT_CODE_FAIL_OLD_VERSON=0x1017;//WIFI����ʧ��-ǰ�˰汾��֧��
  
  
  public static RecordInfo _objRecordConfig= new RecordInfo();
//¼��״̬
  public static final int  RECORD_STAT_UNKOWN =0;
  public static final int  RECORD_STAT_RUN_OK =10;
  public static final int  RECORD_STAT_NO_SDCARD =-11;
  public static final int  RECORD_STAT_SDCARD_WRITE_ERR =-12;
  
  public static String ANDROID_APP_NAME = "V380";   //�������

  public static int APP_UPDATE_RESULT = 2221;
  public static int APP_UPDATE_RESULT_NO_NEW = 1;
  public static int APP_UPDATE_RESULT_HAS_NEW = 2;
  public static int _nCheckVersionNUm = 0;
  public static long _lCheckTime=0;
  public static int APP_ID_ICAMSEE=1011;
  public static int APP_ID_ICAMSEE2=1021;
  public static int APP_ID_V380=1120;
  
  public static String _strUpdate = "update.nvdvr.cn";  //��������������  
  public static final String JSP_SERVER_SOFTWARE_UPDATE= "/AppManage/UpdateSelectServletAppVersionCheck?param=";  //�汾��������
  
  static final int RADIO_INDEX_HOME=100;
  static final int RADIO_INDEX_PIECTURE=101;
  static final int RADIO_INDEX_PLAYBACK=102;
  static final int RADIO_INDEX_HELP=103;
  
  public static boolean IsSoftwareOpen = false;
  public static boolean IsSoftwareRunning = false;
  public static boolean PLAY_BACK_BACK = false; 
  
  public static long _lHandle = -1;
  public static int _nDeviceID =-1;
  public static boolean _isMRMode=false;
  public static String _strMRServer=null;
  public static int _nMRPort=0;
  public static String _strPassword = null; // add by mai 2015-7-21
  public static String _strUserName = null; //add by mai 2015-7-21
	
  public static long _lHandleGetTime = 0;
	
  public static int _nSearchDevID=-1;
  public static String _strSearchIP="127.0.0.1";
  public static  int _nSearchPort=8800;
  public static String _strSearchDomain="127.0.0.1";
	//end add by luo 20141112
  static final int nBuildCount=11;//���ڱ�ʶ�Ƿ��һ������app
  
 
  
   
  public static int _nCurrentID=0;
  public static final int HANDLE_MSG_CODE_LOGIN_RESULT=0x10;//��Ϣ�����ʾ�𣺵�¼���
  public static final int LOGIN_RESULT_CODE_SUCCESS=0x0001;//��¼�ɹ�
  public static final int LOGIN_RESULT_CODE_FAIL_NET_DOWN=0x1001;//��¼ʧ��-���粻ͨ
  public static final int LOGIN_RESULT_CODE_FAIL_NET_POOL=0x1002;//��¼�ɹ�-�������ӳ�ʱ
  public static final int LOGIN_RESULT_CODE_FAIL_SERVER_OFFLINE=0x1003;//��¼ʧ��-������������
  public static final int LOGIN_RESULT_CODE_FAIL_VERIFY_FAILED=0x1004;//��¼ʧ��-��֤����
  public static final int LOGIN_RESULT_CODE_FAIL_USER_NOEXIST=0x1005;//��¼ʧ��-�û���������
  public static final int LOGIN_RESULT_CODE_FAIL_PWD_ERROR=0x1006;//��¼ʧ��-�������
  public static final int LOGIN_RESULT_CODE_FAIL_OLD_VERSON=0x1007;//��¼ʧ��-ǰ�˰汾��֧��
  
  
  public static byte [] _playFaceYUVData = new byte[704*576*3];
  public static final int _YUVWidth=0;//640; 
  public static final int _YUVHeight=480; 
  static byte [] _SockBuf = new byte[Defines.MAX_BUFFER_SIZE]; 
  static final String _fileName= "systemConfig.xml";
  static boolean _isAutoLoginEnable=true;//�Ƿ�ʼ�Զ���¼���ܣ���Ҫ�Ǳ���ϵͳ���ص�¼���������Զ���¼ 
  static boolean isResourrceLoaded=false;
  public static byte [] _ImagePixel = new byte[1280*1280*3];
  public static ByteBuffer _capbuffer = ByteBuffer.wrap(_ImagePixel);
  public static  int _capWidth=640; 
  public static  int _capHeight=480; 
	
  public static  float _PTZXWidth=120; 
  public static  float _PTZXHeight=80; 
  static void loadResource(Resources resource){
		if(resource==null)return;
		if(!isResourrceLoaded){
			if(_ImagePixel==null) _ImagePixel = new byte[1280*960*3];
			
			if(_SockBuf==null)_SockBuf = new byte[Defines.MAX_BUFFER_SIZE];
			
			 
			 ////��ȡplay_welcome_face��yuv����
			 if(_playFaceYUVData==null) _playFaceYUVData = new byte[704*576*3];
			 
			 Arrays.fill(_playFaceYUVData, (byte) ((byte)256*256*256));
			 /*int byteread = 0;
		     InputStream inStream = null;
		     try {
		       
		        	 inStream = resource.openRawResource(R.raw.play_welcome_face1);
			  } catch (Exception e) {
		        	return;
		      }
		      try {
		        	byteread = inStream.read(Defines._playFaceYUVData);
		      } catch (IOException e) {
		        	// TODO Auto-generated catch block
		        	e.printStackTrace();
		        }finally{
		        	try {
						inStream.close();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
		      }
*/
			 ////end ��ȡplay_welcome_face��yuv����
			isResourrceLoaded=true;
		}
		
	   	 
	}
  
  

  public static int _PTZXPointDevID = 0;
  public static HashMap<Integer, PTZXPoint> _ptzxPointList=new HashMap<Integer, PTZXPoint>();
  public static boolean updatePTZXPoints(int nDevID, int nPTZXID, Bitmap image){
		boolean bResult = false;
		PTZXPoint ptzxPoint = null;
		if(_PTZXPointDevID==nDevID){
			
			ptzxPoint = _ptzxPointList.get(nPTZXID);
		}else{
			_ptzxPointList.clear();
		}
		if(ptzxPoint!=null){//����
			
		}else{//����µ�
			 ptzxPoint = new PTZXPoint(0, nDevID, nPTZXID, System.currentTimeMillis(), null);
			 bResult = DatabaseManager.AddPTZXInfo(ptzxPoint);
		}
		
		if(ptzxPoint!=null){
			ptzxPoint.setFaceImage(image);
			ptzxPoint.setlSaveTime(System.currentTimeMillis());
			bResult =DatabaseManager.updatePTZXPoint(ptzxPoint);
			
			_ptzxPointList.remove(nPTZXID);
			_ptzxPointList.put(nPTZXID, ptzxPoint);
			_PTZXPointDevID = nDevID;
		}
		ptzxPoint=null;
		return bResult;
	}
	public static int loadPTZXPoints(int nDevID){
		
		System.out.println("loadPTZXPoints : "+nDevID);//
		
		boolean isToLoad = true;
		if(_PTZXPointDevID==nDevID){
			 isToLoad = false;
		}
		
		if(isToLoad){
			System.out.println("loadPTZXPoints : "+nDevID);//
			PTZXPoint [] ptzxPointsList= DatabaseManager.GetPTZXInfos(nDevID);
			if(ptzxPointsList!=null && ptzxPointsList.length>0){
				_ptzxPointList.clear();
				for(int i=ptzxPointsList.length-1; i>=0; i--){
					_ptzxPointList.put(ptzxPointsList[i].getnPTZXID(), ptzxPointsList[i]);
				}
				_PTZXPointDevID=nDevID;
			}
		}
		return _ptzxPointList.size();
	}
	
	
	
	 public static List<RecordFileInfo> listMapPlayerBackFile = new ArrayList<RecordFileInfo>();
	  //¼���ļ�����
     static final int FILE_TYPE_ALL= 0; //ȫ��
     static final int FILE_TYPE_NORMAL= 1; //��ͨ
     static final int FILE_TYPE_MOTION= 2;//����
     static final int FILE_TYPE_ALARM= 3;//����
     
     public static final int REC_FILE_SEARCH_RESULT_CODE_SUCCESS=0x0011;//WIFI�����ɹ�
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_NET_DOWN=-0x1011;//WIFI����ʧ��-���粻ͨ
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_NET_POOL=-0x1012;//WIFI����ʧ��-�������ӳ�ʱ
	  		
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_SERVER_OFFLINE=-0x1013;//WIFI����ʧ��-������������
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_VERIFY_FAILED=-0x1014;//WIFI����ʧ��-��֤����
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_USER_NOEXIST=-0x1015;//WIFI����ʧ��-�û���������
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_PWD_ERROR=-0x1016;//WIFI����ʧ��-�������
	 public static final int REC_FILE_SEARCH_RESULT_CODE_FAIL_OLD_VERSON=-0x1017;//WIFI����ʧ��-ǰ�˰汾��֧��

	 
	 
		public static final byte AuthModeOpen     = 0x00;
		public static final byte AuthModeWEPOPEN  = 0x01;
		public static final byte AuthModeWEPSHARE = 0x02;
		
		public static final byte AuthModeWPAEAP = 0x03;
		public static final byte AuthModeWPA2EAP = 0x04;
		public static final byte AuthModeWPA1EAPWPA2EAP = 0x05;
		
		public static final byte AuthModeWPAPSKAES = 0x06;
		public static final byte AuthModeWPAPSKTKIP = 0x07;
		public static final byte AuthModeWPAPSKTKIPAES = 0x08;

		public static final byte AuthModeWPA2PSKAES = 0x09;
		public static final byte AuthModeWPA2PSKTKIP = 10;
		public static final byte AuthModeWPA2PSKTKIPAES = 11;

		public static final byte AuthModeWPA1PSKWPA2PSKAES = 12;
		public static final byte AuthModeWPA1PSKWPA2PSKTKIP = 13;
		public static final byte AuthModeWPA1PSKWPA2PSKTKIPAES = 14;
		public static int _nConfigID=0;
		public static long _lConfigIDGenTime=0;
		public static int getConfigID(){
			if(_nConfigID<=0 || (System.currentTimeMillis() - _lConfigIDGenTime>=60000)){
				_nConfigID =  1 + (int)(Math.random() * 10); 
				if(_nConfigID>=10){
					_nConfigID = 9;
				}else if(_nConfigID<=0){
					_nConfigID=1;
				}
			}
			return _nConfigID;
		}
		
		
		   
	    public static final String JSP_SERVER_REGIST_CLIENT = "/GetAlarmMsg/XGPhoneClientRegistered?param=";  //��ȡ������ϸ��Ϣ����
	    public static final String JSP_SERVER_SET_DEVICE_ALARM = "/GetAlarmMsg/ClientWithDeivceRegistered?param=";  //��ȡ������ϸ��Ϣ����
	    public static final String JSP_SERVER_SET_DEVICE_ARRAY_ALARM = "/GetAlarmMsg/ClientWithDeivceArrayRegistered?param=";  //��ȡ������
}
